package cn.yikaojiuguo.student.ui.ask;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import cn.yikaojiuguo.student.R;
import cn.yikaojiuguo.student.support.utils.ViewUtils;
import cn.yikaojiuguo.student.ui.base.BasePopupWindow;

/**
 * Created by cfan_yang on 2016/2/17.
 */
public class AskResultPopupWindow extends BasePopupWindow implements View.OnClickListener{

    private TextView mTv_accept;
    private TextView mTv_refuse;
    private OnItemClickListener mListener;

    public AskResultPopupWindow(Context context, float widthPercent, float heightPercent) {
        super(context, widthPercent, heightPercent);
    }

    public void setOnItemClickListener(OnItemClickListener listener) {
        this.mListener = listener;
    }

    @Override
    protected void initEvent() {
        mTv_accept.setOnClickListener(this);
        mTv_refuse.setOnClickListener(this);
    }

    @Override
    protected void initView(Context context) {
        mTv_accept = ViewUtils.find(mConvertView,R.id.tv_accept);
        mTv_refuse = ViewUtils.find(mConvertView,R.id.tv_refuse);
    }

    @Override
    protected int getLayoutResourceId() {
        return R.layout.popup_ask_result;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_accept:
                if(mListener!=null) {
                    mListener.accept();
                }
                break;
            case R.id.tv_refuse:
                if(mListener!=null) {
                    mListener.refuse();
                }
                break;
        }
    }

    public interface OnItemClickListener {
        void accept();
        void refuse();
    }
}
